Skip to content

ENH: add streaming and invalid-encoding tests for AnatomicalOrientation#6536

Merged
blowekamp merged 1 commit into
InsightSoftwareConsortium:mainfrom
blowekamp:test-anatomical-orientation-coverage
Jul 1, 2026
Merged

ENH: add streaming and invalid-encoding tests for AnatomicalOrientation#6536
blowekamp merged 1 commit into
InsightSoftwareConsortium:mainfrom
blowekamp:test-anatomical-orientation-coverage

Conversation

@blowekamp

Copy link
Copy Markdown
Member

Add 5 GTest cases to itkAnatomicalOrientationGTest.cxx that cover the
four operator<< overloads and the default branch of
ConvertStringEncoding, raising line coverage from 76.6 % to 95.0 %
and function coverage from 77.8 % to 100 %.

Coverage detail
Metric Before After
Lines 76.6 % (108/141) 95.0 % (134/141)
Functions 77.8 % (14/18) 100 % (18/18)

New tests:

  • StreamingCoordinateEnum — all 7 CoordinateEnum values via operator<<
  • StreamingPositiveEnumoperator<<(PositiveEnum)
  • StreamingNegativeEnumoperator<<(NegativeEnum)
  • StreamingOrientationoperator<<(AnatomicalOrientation) (outputs space-separated term strings)
  • InvalidNegativeStringEncodingGetAsNegativeStringEncoding() on an INVALID orientation exercises the default branch of ConvertStringEncoding

Remaining 7 uncovered lines are dead-code guards (default: itkGenericExceptionMacro unreachable from a 3×3 matrix) and gcov static-init artifacts.

AI assistance
  • Tool: GitHub Copilot (Claude Sonnet 4.6)
  • Role: identified uncovered lines via gcovr, wrote and validated the five new test cases
  • All 9 AnatomicalOrientation tests pass locally against the coverage preset build

@github-actions github-actions Bot added type:Enhancement Improvement of existing methods or implementation type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct area:Core Issues affecting the Core module labels Jun 30, 2026
Comment thread Modules/Core/Common/test/itkAnatomicalOrientationGTest.cxx
@blowekamp blowekamp force-pushed the test-anatomical-orientation-coverage branch from 4a41565 to 12de472 Compare July 1, 2026 15:13
@blowekamp blowekamp marked this pull request as ready for review July 1, 2026 15:44
@greptile-apps

greptile-apps Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds more coverage for AnatomicalOrientation streaming and invalid encoding behavior. The main changes are:

  • New GTest cases for the CoordinateEnum, PositiveEnum, NegativeEnum, and AnatomicalOrientation stream operators.
  • A new invalid-orientation test for GetAsNegativeStringEncoding().
  • A production change in ConvertStringEncoding() for non-3-character strings.

Confidence Score: 4/5

One contained issue should be fixed before merging.

The tests are focused, but the ConvertStringEncoding change introduces a public API contract regression for non-3-character inputs.

Modules/Core/Common/src/itkAnatomicalOrientation.cxx

T-Rex T-Rex Logs

What T-Rex did

  • Ran a focused C++ harness for itk::AnatomicalOrientation::ConvertStringEncoding to verify the documented involution behavior, and observed that converting 'RA' yields 'INVALID' instead of 'LP', with double-conversion of 'RA' not restoring it and 'INVALID' remaining 'INVALID'.
  • Captured and attached artifacts, including the harness source and the runtime output log, to document the ConvertStringEncoding regression.
  • Compared the streaming-operators before/after captures from the base and head worktrees and confirmed four named streaming tests appear after head, with expected outputs and a passing source-contract harness.

View all artifacts

T-Rex Ran code and verified through T-Rex

Important Files Changed

Filename Overview
Modules/Core/Common/src/itkAnatomicalOrientation.cxx Adds invalid-string handling to ConvertStringEncoding, but the size guard changes the documented no-validation/involution behavior for non-3-character inputs.
Modules/Core/Common/test/itkAnatomicalOrientationGTest.cxx Adds GTest coverage for stream operators and invalid negative string encoding; tests cover the new behavior but not the public helper's existing contract.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant Test as GTest cases
participant AO as itk::AnatomicalOrientation
participant Stream as operator<< overloads
participant Conv as ConvertStringEncoding

Test->>Stream: stream CoordinateEnum / PositiveEnum / NegativeEnum / orientation
Stream->>AO: read orientation terms or string encoding
AO-->>Stream: term strings or acronym
Stream-->>Test: formatted output
Test->>AO: CreateFromPositiveStringEncoding("bad")
AO-->>Test: INVALID orientation
Test->>AO: GetAsNegativeStringEncoding()
AO->>Conv: ConvertStringEncoding("INVALID")
Conv-->>AO: "INVALID"
AO-->>Test: invalid negative encoding
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant Test as GTest cases
participant AO as itk::AnatomicalOrientation
participant Stream as operator<< overloads
participant Conv as ConvertStringEncoding

Test->>Stream: stream CoordinateEnum / PositiveEnum / NegativeEnum / orientation
Stream->>AO: read orientation terms or string encoding
AO-->>Stream: term strings or acronym
Stream-->>Test: formatted output
Test->>AO: CreateFromPositiveStringEncoding("bad")
AO-->>Test: INVALID orientation
Test->>AO: GetAsNegativeStringEncoding()
AO->>Conv: ConvertStringEncoding("INVALID")
Conv-->>AO: "INVALID"
AO-->>Test: invalid negative encoding
Loading

Reviews (1): Last reviewed commit: "ENH: add streaming and invalid-encoding ..." | Re-trigger Greptile

Comment thread Modules/Core/Common/src/itkAnatomicalOrientation.cxx Outdated
@blowekamp blowekamp force-pushed the test-anatomical-orientation-coverage branch from 12de472 to 7f03697 Compare July 1, 2026 16:41
@blowekamp blowekamp merged commit 8ff11b1 into InsightSoftwareConsortium:main Jul 1, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Core Issues affecting the Core module type:Enhancement Improvement of existing methods or implementation type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants